package com.optitronics.validators;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;

import com.optitronics.ui.PasswordForm;

@Component
public class PasswordValidator {

	/**
	 * Validates if password and it's confirmation are the same
	 * 
	 * @param formObject
	 * @param errors
	 */
	public void validatePasswordsMatch(PasswordForm formObject, Errors errors) {

		if (!formObject.getPassword().equals(formObject.getPasswordConfirmation())) {
			errors.rejectValue("password", "error.password.do.not.match");
		}

	}

}
